package com.iwhalecloud.bss.kite.cucc.web.controller.custview;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.iwhalecloud.bss.kite.client.dto.DataResult;
import com.iwhalecloud.bss.kite.common.constant.ErrorConsts;
import com.iwhalecloud.bss.kite.cucc.client.api.custview.ICustViewService;
import com.iwhalecloud.bss.kite.cucc.client.dto.custview.MemUserQueryReq;
import com.iwhalecloud.bss.kite.cucc.client.dto.order.UserQueryDTO;
import com.iwhalecloud.bss.kite.cucc.client.dto.webService.CustContractRsp;
import com.iwhalecloud.bss.kite.cucc.client.vo.custview.CustViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * @ClassName : CustViewController
 * @Description : 订购信息
 * @Author : xie.zhengjun
 * @Date : 2021/1/11 15:42
 */
@Api(tags = {"/custView - 订购信息"})
@RestController
@RequestMapping("/custView")
public class CustViewController {

    @Resource
    private ICustViewService custViewService;

    @ApiOperation(value = "查询集团信息", notes = "查询集团信息")
    @ApiImplicitParams({@ApiImplicitParam(name = "accNum", value = "业务号码", required = true),
    @ApiImplicitParam(name = "provinceCode", value = "省份编码", required = false),
    @ApiImplicitParam(name = "eparchyCode", value = "地市编码", required = false),
    @ApiImplicitParam(name = "userId", value = "用户标识", required = false)
    })
    @GetMapping
    public DataResult<CustViewVO> getCustView(@RequestParam String accNum, @RequestParam String userState,
                                              @RequestParam String provinceCode,@RequestParam String eparchyCode,
                                              @RequestParam(required = false) String userId) {

        return ErrorConsts.SUCCESS.getResult(custViewService.getCustViewEvolve(accNum, userState,provinceCode,eparchyCode,userId));
    }

    @ApiOperation(value = "查询用户列表", notes = "查询用户列表")
    @PostMapping("/member/users")
    public DataResult<UserQueryDTO> queryUserList(@RequestBody MemUserQueryReq memUserQueryReq) {
        return ErrorConsts.SUCCESS.getResult(custViewService.queryUserList(memUserQueryReq));
    }

    @ApiOperation(value = "查询合同详情", notes = "查询合同详情")
    @ApiImplicitParams({@ApiImplicitParam(name = "custId", value = "客户标识", required = true),
        @ApiImplicitParam(name = "provinceCode", value = "省份编码", required = true),
        @ApiImplicitParam(name = "contractId", value = "合同标识", required = true),
        @ApiImplicitParam(name = "goodId", value = "分类标识", required = true),
        @ApiImplicitParam(name = "contractType", value = "分类标识", required = true)

    })
    @GetMapping("/contract")
    public DataResult<CustContractRsp> getContractInfo(@RequestParam String custId, @RequestParam String provinceCode,
                                                       @RequestParam String contractId,@RequestParam String goodId,@RequestParam String contractType) {
        return ErrorConsts.SUCCESS.getResult(custViewService.getContractInfo(custId, provinceCode, contractId,goodId,contractType));
    }
}
